﻿using LiteDB;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using TestingApp.Pages;
using TestingApp.Services;
using TestingApp.ViewModels;
using TestingApp.ViewModels.Admin;

namespace TestingApp {
    public static class Ioc  {

        private static ServiceProvider _provider;

        static Ioc() {
            var services = new ServiceCollection();

            services.AddSingleton<MainViewModel>();
            services.AddSingleton<SelectRolePageViewModel>();
            services.AddSingleton<TeacherLoginPageViewModel>();
            services.AddSingleton<AdminPageViewModel>();
            services.AddTransient<TestEditorPageViewModel>();

            services.AddSingleton<PageService>();
            services.AddSingleton( new LiteDatabase("Data/test-app.db")) ;
            services.AddTransient<Repository>();

            _provider = services.BuildServiceProvider();
        }

        public static T Resolve<T>() => _provider.GetRequiredService<T>();
        
    }
}
